import com.sun.media.jfxmediaimpl.HostUtils;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2023-05-13
 * Time: 10:47
 */
class Shap{
    public  void draw(){
        System.out.println("画图形！");
    }
}
class Rect extends Shap{
    @Override
    public void draw() {
        System.out.println("画矩形！");
    }
}
class Cycle extends Shap{
    @Override
    public void draw() {
        System.out.println("画圆！");
    }
}
class Flower extends Shap{
    @Override
    public void draw() {
        System.out.println("画一朵花❀！");
    }
}
public class Test3 {
    public static void drawMap(Shap shap){
        shap.draw();
    }
    public static void drawMap2(){
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        //c r c r f
        String[] shapes = {"cycle", "rect", "cycle", "rect", "flower"};
        for (String shape : shapes) {
            if (shape.equals("cycle")) {
                cycle.draw();
            } else if (shape.equals("rect")) {
                rect.draw();
            } else if (shape.equals("flower")) {
                flower.draw();
            }
        }
    }
    public static void drawMap3(){
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();
        Shap [] shaps = {cycle,rect,cycle,rect,flower};
        for(Shap shap:shaps){
            shap.draw();
        }
    }
    public static void main(String[] args) {
/*        Rect rect = new Rect();
        Cycle cycle = new Cycle();

        drawMap(rect);
        drawMap(cycle);
        drawMap(new Flower());
        System.out.println("====================");*/
        drawMap3();
    }
}
